﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Designer.Views
{
    public class WorkSpaceViewModel
    {
        public static explicit operator Designtime.Metadata.LocalWorkSpace(WorkSpaceViewModel source)
        {
            Designtime.Metadata.LocalWorkSpace dest = new Designtime.Metadata.LocalWorkSpace();
            dest.Id = source.Id;
            dest.Computer = source.Computer;
            dest.LocalPath = source.LocalPath;
            dest.CreatedTime = source.CreatedTime;
            dest.Creator = source.Creator;
            return dest;
        }


        public Guid Id { get; set; }

        /// <summary>
        /// 计算机名称
        /// </summary>
        public string Computer { get; set; }

        private string _LocalPath;
        /// <summary>
        /// 本地存储路径
        /// </summary>
        public string LocalPath
        {
            get { return _LocalPath; }
            set { _LocalPath = value; }
        }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }

        public string CreatedTimeString { get { return CreatedTime.ToString("yyyy-MM-dd"); } }
        public string Creator { get; set; }

        public bool IsMapping
        {
            get
            {
                if (string.Equals(UIContext.Current.ComputerName, Computer) && System.IO.Directory.Exists(LocalPath))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
    }
}
